home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.11 Nov 91 / Icon List source / CIconItemObj.c next >
Encoding:
C/C++ Source or Header  |  1990-07-28  |  1.2 KB  |  50 lines  |  [TEXT/KAHL]

  1. /*    ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  2.     Icon List Item Object
  3.  
  4.     Defines an object that holds an icon from a resource file
  5.     |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
  6.  
  7. #include "CIconItemObj.h"
  8. #include <color.h>
  9.  
  10. /* |||||||||||||||||||| */
  11.  void CIconItemObj::DrawItem ( Boolean selected, Rect *dispR )
  12.     {
  13.     Rect                arect;
  14.     Str255            numStr;
  15.     
  16.     /*** draw an icon item (expects dispR to be at least 40 pixels high) */
  17.     EraseRect ( dispR );
  18.     
  19.     /*** draw the icon (inset by 4 pixels) */
  20.     arect = *dispR;
  21.     arect.top += 4;
  22.     arect.bottom = arect.top +32;
  23.     arect.left += 4;
  24.     arect.right = arect.left + 32;
  25.     PlotIcon ( &arect, bits );
  26.     
  27.     /*** display the name and id next to it */
  28.     TextFont ( systemFont );
  29.     TextSize ( 12 );
  30.     TextFace ( 0 );
  31.     arect.left = arect.right + 8;
  32.     arect.right = arect.left + 40;
  33.     arect.top += 9;
  34.     arect.bottom -= 9;
  35.     NumToString ( (long) id, numStr );
  36.     TextBox ( &numStr[1], (int) numStr[0], &arect, teJustLeft );
  37.     
  38.     TextFont ( geneva );
  39.     TextSize ( 9 );
  40.     arect.left = arect.right + 8;
  41.     arect.right = dispR->right;
  42.     arect.bottom += 16;
  43.     TextBox ( &name[1], (int) name[0], &arect, teJustLeft );
  44.     
  45.     /*** if selected, invert the rect (could use hilite mode) */
  46.     if ( selected ) {
  47.         InvertRect ( dispR );
  48.         }
  49.     }
  50.